# ./kvstore2pcsystem --config_path ./src/participant_sample.conf

CPP = g++
CXXFLAGS = -std=c++11 -O2 -g 
INCLUDE = -I./include  -I./third_party
LIB = -lpthread

# all: kvstore2pcsystem kvstoreraftsystem test_raft auto
all: kvstoreraftsystem raft

raft: test.o raft.o follower.o ossSocket.o parser.o kv.o network.o  logger.o utils.o
	$(CPP) $(CXXFLAGS) $(INCLUDE) -o $@ $^ $(LIB)
kvstoreraftsystem: mainraft.o raft.o follower.o kvstore2pcsystem.o ossSocket.o parser.o kv.o network.o  logger.o utils.o
	$(CPP) $(CXXFLAGS) $(INCLUDE) -o $@ $^ $(LIB)
mainraft.o: main_raft.cc
	$(CPP) $(CXXFLAGS) $(INCLUDE) -c -o $@ $^
kvstore2pcsystem: main2pc.o kvstore2pcsystem.o coordinator.o participant.o ossSocket.o parser.o kv.o network.o  logger.o utils.o 
	$(CPP) $(CXXFLAGS) $(INCLUDE) -o $@ $^ $(LIB)
test.o: test.cc
	$(CPP) $(CXXFLAGS) $(INCLUDE) -c -o $@ $^
main2pc.o: main_2pc.cc
	$(CPP) $(CXXFLAGS) $(INCLUDE) -c -o $@ $^
kvstore2pcsystem.o:  kvstore2pcsystem.cc
	$(CPP) $(CXXFLAGS) $(INCLUDE) -c -o $@ $^
coordinator.o: coordinator.cpp
	$(CPP) $(CXXFLAGS) $(INCLUDE) -c -o $@ $^
participant.o:  participant.cpp
	$(CPP) $(CXXFLAGS) $(INCLUDE) -c -o $@ $^
ossSocket.o : ./third_party/ossSocket.cc
	$(CPP) $(CXXFLAGS) -c $^  $(LIB) $(INCLUDE)
parser.o : parser.cpp
	$(CPP) $(CXXFLAGS) -c $^  $(LIB) $(INCLUDE)
kv.o : kv.cc
	$(CPP) $(CXXFLAGS) -c $^  $(LIB) $(INCLUDE)
network.o : network.cc
	$(CPP) $(CXXFLAGS) -c $^  $(LIB) $(INCLUDE)
logger.o : logger.cc
	$(CPP) $(CXXFLAGS) -c $^  $(LIB) $(INCLUDE)
utils.o : utils.cc
	$(CPP) $(CXXFLAGS) -c $^  $(LIB) $(INCLUDE)
raft.o : raft.cc
	$(CPP) $(CXXFLAGS) -c $^  $(LIB) $(INCLUDE)
follower.o : follower.cpp
	$(CPP) $(CXXFLAGS) -c $^  $(LIB) $(INCLUDE)

.PHONY: clean

auto:
	rm -f *.o src/*.gch
clean:
	rm -f kvstore2pcsystem kvstoreraft *.o src/*.gch
